<?php

	class detailsClass{
		
		function __construct(){
			@$bb=$_GET['func'];
			if($bb=="flipmax"){
			$this->flipmax();
			}elseif($bb=="flipmin"){
			$this->flipmin();
			}else{
			$this->details1();
		}
		}
	    function details1(){
	    	$id=$_GET['id'];
			$click=mysql_query("select * from test_papapa where id='$id'");
			$click=mysql_fetch_object($click);
			$click=$click->click;
			//查找之前的点击量，加1后，修改，再查找出来
			$click=$click+1;
			mysql_query("update test_papapa set click='$click' where id='$id'  ");
			
			
	    	$sql=mysql_query("select * from test_papapa where id='$id'  ");
	    	$rel=mysql_fetch_object($sql);
	    	require_once("./home/static/details1.php");
			
	    }
		
		function flipmax(){
		$id=$_GET['id'];
	    $sql=mysql_query("select * from test_papapa where id > $id order by id asc limit 1");
		$rel=mysql_fetch_object($sql);
		$maxid=mysql_query("select max(id) as maxid from test_papapa");
		
		$max=mysql_fetch_object($maxid);
		$maxid=$max->maxid ;
		if($id==$maxid){
			echo "<script>alert('已经是第一篇了');history.back(); </script>";
		}
		//判断第一个
		
		require_once("./home/static/details1.php");
		}
		
		function flipmin(){
		$id=$_GET['id'];
	    $sql=mysql_query("select * from test_papapa where id < $id order by id desc limit 1");
		$rel=mysql_fetch_object($sql);
		//判断最后个
		$sql1=mysql_query("SELECT min(id) as minid FROM test_papapa");
		$minid=mysql_fetch_object($sql1);
	    $minid=$minid->minid;
		 if($id==$minid){
		 	echo "<script>alert('已经是最后一篇');history.back();</script>";
		 }
		
		
		require_once("./home/static/details1.php");
			
		}
		
	}
	
	?>